<script setup lang="ts">
import { NConfigProvider, NLoadingBarProvider, NMessageProvider, NNotificationProvider, NModalProvider, NDialogProvider } from 'naive-ui'
import { useMenuStore } from './stores/menuStore'; // 引入 Pinia store

const menuStore = useMenuStore();


// 全局的右键菜单项
const globalMenuItems = [
  { id: 'edit', text: '刷新', action: () =>  window.location.reload()},
  { id: 'delete', text: '全局删除', action: () => console.log('执行全局删除') },
];



// 右键点击事件，显示全局右键菜单
const onContextMenu = (event: MouseEvent) => {
  event.preventDefault();
  menuStore.resetMenu(); // 重置当前菜单项
  menuStore.setMenu(globalMenuItems, { x: event.clientX, y: event.clientY });
};

</script>

<template>
  <n-config-provider>
    <n-loading-bar-provider>
      <n-message-provider>
        <n-notification-provider>
          <n-modal-provider>
            <n-dialog-provider>
              <div @contextmenu="onContextMenu">
                <router-view></router-view>
              </div>
            </n-dialog-provider>
          </n-modal-provider>
        </n-notification-provider>
      </n-message-provider>
    </n-loading-bar-provider>
  </n-config-provider>


</template>

<style>
html,
body,
#app {
    height: 100%;
    margin: 0;
    padding: 0;
    scrollbar-width: none;
}



/* 滚动条宽度 */
::-webkit-scrollbar {
  width: 1px;
  height: 1px;
}

.draggable-card {
  /* 允许内部接收所有鼠标事件 */
  -webkit-app-region: no-drag;
  pointer-events: auto !important;
}
</style>